nt_user_can( 'activate_plugins' ); $strings['can_activate_addons'] = $can_activate_plugins; if ( ! $can_activate_plugins ) { /* translators: %s - addon name. */ $strings['activate_prompt'] = '

' . esc_html( sprintf( __( 'The %s is not activated. Please contact the site administrator.', 'wpforms-lite' ), '%name%' ) ) . '

'; } $upgrade_utm_medium = wpforms_is_admin_page() ? 'Settings - Integration' : 'Builder - Settings'; $strings['upgrade'] = [ 'pro' => [ 'title' => esc_html__( 'is a PRO Feature', 'wpforms-lite' ), 'title_plural' => esc_html__( 'are a PRO Feature', 'wpforms-lite' ), 'message' => '

' . esc_html( sprintf( /* translators: %s - addon name. */ __( 'We\'re sorry, the %s is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wpforms-lite' ), '%name%' ) ) . '

', 'doc' => sprintf( '%2$s', esc_url( wpforms_utm_link( 'https://wpforms.com/docs/upgrade-wpforms-lite-paid-license/#installing-wpforms', $upgrade_utm_medium, 'AP - %name%' ) ), esc_html__( 'Already purchased?', 'wpforms-lite' ) ), 'button' => esc_html__( 'Upgrade to PRO', 'wpforms-lite' ), 'url' => wpforms_admin_upgrade_link( $upgrade_utm_medium ), 'url_template' => wpforms_is_admin_page( 'templates' ) ? wpforms_admin_upgrade_link( 'Form Templates Subpage' ) : wpforms_admin_upgrade_link( 'builder-modal-template' ), 'modal' => wpforms_get_upgrade_modal_text( 'pro' ), ], 'elite' => [ 'title' => esc_html__( 'is an Elite Feature', 'wpforms-lite' ), 'title_plural' => esc_html__( 'are an Elite Feature', 'wpforms-lite' ), 'message' => '

' . esc_html( sprintf( /* translators: %s - addon name. */ __( 'We\'re sorry, the %s is not available on your plan. Please upgrade to the Elite plan to unlock all these awesome features.', 'wpforms-lite' ), '%name%' ) ) . '

', 'doc' => sprintf( '%2$s', esc_url( wpforms_utm_link( 'https://wpforms.com/docs/upgrade-wpforms-lite-paid-license/#installing-wpforms', $upgrade_utm_medium, 'AP - %name%' ) ), esc_html__( 'Already purchased?', 'wpforms-lite' ) ), 'button' => esc_html__( 'Upgrade to Elite', 'wpforms-lite' ), 'url' => wpforms_admin_upgrade_link( $upgrade_utm_medium ), 'url_template' => wpforms_is_admin_page( 'templates' ) ? wpforms_admin_upgrade_link( 'Form Templates Subpage' ) : wpforms_admin_upgrade_link( 'builder-modal-template' ), 'modal' => wpforms_get_upgrade_modal_text( 'elite' ), ], ]; $strings['upgrade_bonus'] = wpautop( wp_kses( __( 'Bonus: WPForms Lite users get 50% off regular price, automatically applied at checkout.', 'wpforms-lite' ), [ 'strong' => [], 'span' => [], ] ) ); $strings['thanks_for_interest'] = esc_html__( 'Thanks for your interest in WPForms Pro!', 'wpforms-lite' ); return $strings; } /** * Ajax handler for the education dismiss buttons. * * @since 1.6.6 */ public function ajax_dismiss() { // Run a security check. check_ajax_referer( 'wpforms-education', 'nonce' ); // Section is the identifier of the education feature. // For example: in Builder/DidYouKnow feature used 'builder-did-you-know-notifications' and 'builder-did-you-know-confirmations'. $section = ! empty( $_POST['section'] ) ? sanitize_key( $_POST['section'] ) : ''; if ( empty( $section ) ) { wp_send_json_error( [ 'error' => esc_html__( 'Please specify a section.', 'wpforms-lite' ) ] ); } // Check for permissions. if ( ! $this->current_user_can() ) { wp_send_json_error( [ 'error' => esc_html__( 'You do not have permission to perform this action.', 'wpforms-lite' ) ] ); } $user_id = get_current_user_id(); $dismissed = get_user_meta( $user_id, 'wpforms_dismissed', true ); if ( empty( $dismissed ) ) { $dismissed = []; } $dismissed[ 'edu-' . $section ] = time(); update_user_meta( $user_id, 'wpforms_dismissed', $dismissed ); wp_send_json_success(); } /** * Whether the current user can perform an action. * * @since 1.8.0 * * @return bool */ private function current_user_can() { // phpcs:ignore WordPress.Security.NonceVerification.Missing $page = ! empty( $_POST['page'] ) ? sanitize_key( $_POST['page'] ) : ''; // key is the same as $current_screen->id and the JS global 'pagenow', value - capability name(s). $caps = [ 'toplevel_page_wpforms-overview' => [ 'view_forms' ], 'wpforms_page_wpforms-builder' => [ 'edit_forms' ], 'wpforms_page_wpforms-entries' => [ 'view_entries' ], ]; return isset( $caps[ $page ] ) ? wpforms_current_user_can( $caps[ $page ] ) : wpforms_current_user_can(); } }